﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RecipesManager.RecipesImporter
{
    //Classe per contenere un ingrediente importato col RecipeImporter
    public class ImportedIngredient
    {
      #region Data
      public string Name { get; set; }
      public string Quantity { get; set; }
      public string Note { get; set; }

      public ImportedIngredient(string name, string quantity, string note)
      {
        Name = name;
        Quantity = quantity;
        Note = note;
      }

      public int getQuantityNumber()
      {
        int number;
        try
        {
          number = Convert.ToInt32(Quantity.Split(' ')[0]);
        }
        catch (FormatException e)
        {
          return 0;
        }
        
        return number;
      }

      public string getQuantityMeasure()
      {
        string measure;
        
        try
        {
          measure = Quantity.Split(' ')[1];
        }
        catch (FormatException e)
        {
          return "";
        }

        return measure;
      }
          

      #endregion
    }
}
